package global;

import java.io.*;

public class TID {
	public int slotNo;

	/**
	 * public PageId pageNo
	 */
	public PageId pageNo = new PageId();

	/**
	   * 
	   */
	public TID() {

	}

	public TID(PageId pageno, int slotno) {
		pageNo = pageno;
		slotNo = slotno;
	}

	public void copyTid(TID tid) {
		pageNo = tid.pageNo;
		slotNo = tid.slotNo;
	}

	public void writeToByteArray(byte[] ary, int offset)
			throws java.io.IOException {
		Convert.setIntValue(pageNo.pid, offset, ary);
		Convert.setIntValue(slotNo, offset + 4, ary);
	}

	/**
	 * Compares two RID object, i.e, this to the rid
	 * 
	 * @param rid
	 *            RID object to be compared to
	 * @return true is they are equal false if not.
	 */
	public boolean equals(TID tid) {

		if ((this.pageNo.pid == tid.pageNo.pid) && (this.slotNo == tid.slotNo))
			return true;
		else
			return false;
	}

}
